<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <title>列表</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath }/js/layui/css/layui.css" media="all">
    <script type="text/html" id="barresume">
        <a class="layui-btn layui-btn-xs" lay-event="edit">
            <i class="layui-icon layui-icon-edit"></i>编辑
        </a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">
            <i class="layui-icon layui-icon-delete"></i>删除
        </a>
    </script>
</head>
<body>
    <form class="layui-form layui-form-pane">
        <div class="layui-inline">
            <div class="layui-input-inline">
                <a class="layui-btn layui-btn-radius layui-btn-normal case_button floatright" lay-event="add">
                    <i class="layui-icon">&#xe608;</i>添加
                </a>
            </div>
        </div>
    </form>
    <table class="layui-hide" id="resumeList" lay-filter="resumeList"></table>

    <script type="text/javascript" src="${pageContext.request.contextPath }/js/common/html5.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/common/respond.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/common/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/layui/layui.js" charset="utf-8"></script>
    <script>
        function getRootPath() {
            var curWwwPath = window.document.location.href;

            var pathName = window.document.location.pathname;

            var pos = curWwwPath.indexOf(pathName);

            var localhostPath = curWwwPath.substring(0, pos);

            console.log("当前主机地址：" + localhostPath);

            var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);

            console.log("当前项目名称：" + projectName);

            return localhostPath+projectName;

        }
        layui.use(['form','layer','table','laydate'],function() {
            var form = layui.form,
                layer = layui.layer,
                $ = layui.jquery,
                table = layui.table,
                laydate = layui.laydate;

            table.render({
                elem: '#resumeList'
                ,url:getRootPath()+'/doFindResume'
                ,page: true
                ,limits : [2,4,6,8,10]
                ,limit : 2
                ,cellMinWidth: 80
                ,id : "resumeTable"
                ,cols: [[
                    {field:'userId',align: 'center',title: 'ID', sort: true}
                    ,{field:'userName',align: 'center',title: '用户名'}
                    ,{field:'password',align: 'center', title: '密码', sort: true}
                    ,{fixed: 'right', title:'操作', toolbar: '#barresume', width:150}
                ]]
            });
            // 删除
            table.on('tool(resumeList)', function(obj){
                var data = obj.data;
                if(obj.event === 'del'){
                    layer.confirm('真的删除行么？', function(index){
                        $.get(getRootPath()+'/doDeleteResume',{userId:data.userId},function (d) {
                            layer.close(index);
                            if (d.code == 0) {
                                obj.del();
                                layer.msg("删除成功");
                            }else{
                                layer.msg("删除失败");
                            }
                        },"json");
                    });
                }
            });
        });
    </script>
</body>
</html>
